From b98616102540365362c4b41edff14d45a6cb9633 Mon Sep 17 00:00:00 2001 From: justbur Date: Tue, 5 Apr 2016 10:04:54 -0400 Subject: [PATCH] Add tests --- which-key-tests.el | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 which-key-tests.el diff --git a/which-key-tests.el b/which-key-tests.el new file mode 100644 index 00000000000..e5c8c4a05f0 --- /dev/null +++ b/which-key-tests.el @@ -0,0 +1,57 @@ +;;; which-key-tests.el --- Tests for which-key.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 Justin Burkett + +;; Author: Justin Burkett +;; URL: https://github.com/justbur/emacs-which-key + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Tests for which-key.el + +;;; Code: + +(require 'which-key) +(require 'ert) + +(ert-deftest which-key-test-prefix-declaration () + "Test `which-key-declare-prefixes' and +`which-key-declare-prefixes-for-mode'. See Bug #109." + (let* (test-mode which-key-prefix-name-alist which-key-prefix-title-alist) + (which-key-declare-prefixes + "SPC C-c" '("complete" . "complete title") + "SPC C-k" "cancel") + (which-key-declare-prefixes-for-mode 'test-mode + "C-c C-c" '("complete" . "complete title") + "C-c C-k" "cancel") + (should (equal + (assoc-string "SPC C-k" which-key-prefix-name-alist) + '("SPC C-k" . "cancel"))) + (should (equal + (assoc-string + "C-c C-c" (cdr (assq 'test-mode which-key-prefix-name-alist))) + '("C-c C-c" . "complete"))) + (pp which-key-prefix-title-alist) + (should (equal + (assoc-string "SPC C-k" which-key-prefix-title-alist) + '("SPC C-k" . "cancel"))) + (should (equal + (assoc-string + "C-c C-c" (cdr (assq 'test-mode which-key-prefix-title-alist))) + '("C-c C-c" . "complete title"))))) + +(provide 'which-key-tests) +;;; which-key-tests.el ends here -- 2.30.2